<?php
namespace pgc;
use \hc\tpl;
use \hc\session;
use \hc\js;
use \hc\upload;
class Uploads extends tpl{
	public function __construct(){
		parent::__construct();
		session::init();
    if(isset($_SESSION['pgcinfo'])){
				$this->pgcinfo=$_SESSION['pgcinfo'];
		}else{
				$url=MODEL_URL."/Login/index.html";
			 echo 	js::to_url($url);exit;
		}
    $this->up=new upload();
	}
  public function upload_face(){
    $setconfig[]=array('pathFormat',2);
    $setconfig[]=array('savePath','userface');
    $setconfig[]=array('exts',array('gif','jpeg','png','jpg'));
    $this->upcom($_FILES['faceUpload'],$setconfig);
  }
  private function upcom($files,$setconfig=array()){
		if(!empty($setconfig)){
			$this->up->setconfig($setconfig);
		}
		$info=$this->up->upload_one($files);
		if(!$info){
			$return['status']=false;
			$return['msg']=$this->up->getError();
		}else{
			$return['status']=true;
			$return['msg']="上传成功";
			//$return['img']=$info[0];
			$img=BASE_URL."/".trim($info[0],'./');
			$return['img']=$img;
		}
		$return=json_encode($return);
		$str = '<script type="text/javascript">window.parent.upfile('.$return.')</script>';
		echo $str;
	}


}
?>
